<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="识别图状态">
        <el-select
          v-model="typeList[form.type]"
          placeholder="请选择"
          @change="onchengType"
        >
          <el-option
            label="普通识别图"
            value="0"
          />
          <el-option
            label="万能识别图"
            value="1"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="选择识别图">
        <imageUpload
          :imgsrc="form.image"
          @oncheng="form.image =$event.url,form.targetId=$event.id"
        />
      </el-form-item>

      <el-form-item label="识别图描述">
        <el-input v-model="form.detail" type="textarea" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确 认</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import imageUpload from '@/components/imageUpload/arsbtupload'
import sbtApi from '@/api/sbtApi'
export default {
  inject: [
    'reload'
  ],
  components: {
    imageUpload
  },
  data() {
    return {
      form: {
        'describe': '',
        'id': '',
        'image': '',
        'targetId': '',
        'type':0
      },
      typeList:["普通识别图","万能识别图"]
    }
  },
  methods: {
    onSubmit() {
      sbtApi.addSbt(this.form).then(res=>{
        console.log(res)
        this.$message.success('新增成功')
        this.reload()
      })
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      })
    },
    onchengType(e){
      this.form.type = e
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

